package com.java.exer_3;

import java.util.Calendar;

/**
 * @author shkstart
 * @create 2021-01-12 11:11
 */
public class DateTimeExer_3 {
    public static void main(String[] args) {
        for (int i = 1; i <= 12; i++) {
            CalendarTest(i);
            System.out.println();

        }
    }

    public static void CalendarTest(int mouth) {
        //修正月份为0··11
        mouth--;
        //创建Calendar实例化对象
        Calendar c1 = Calendar.getInstance();
        //设置当前月份
        c1.set(Calendar.MONTH, mouth);
        //设置当前天为1号
        c1.set(Calendar.DAY_OF_MONTH, 1);
        System.out.println("--------本月是" + (mouth + 1) + "月----------");

        System.out.println("日" + "\t" + "一" + "\t" + "二" + "\t" + "三" + "\t" + "四" + "\t" + "五" + "\t" + "六");
        //补足1号之前的空白天
        for (int i = 0; i < 0 - 1; i++) {
            System.out.print("\t");
        }
        //判断
        while (c1.get(Calendar.MONTH) == mouth) {

            int day = c1.get(Calendar.DAY_OF_MONTH);
            System.out.print(day + "\t");
            //判断是否为7
            if (c1.get(Calendar.DAY_OF_WEEK) == 7) {
                System.out.println();
            }
            c1.add(Calendar.DAY_OF_MONTH, 1);
        }
    }
}

